#!/bin/bash
##export SERVICE_PORT=5042

# 服务端口
SERVICE_PORT=${SERVICE_PORT:-unknown}

if [ $SERVICE_PORT == "unknown" ]; then
    echo "Warnings: 必填参数 SERVICE_PORT 丢失。"
    exit 1
fi

WEB_STATUS=100
TIME_WAIT=0

echo Final.健康检查
while [ $WEB_STATUS -gt 0 ]
do
  curl -s http://127.0.0.1:$SERVICE_PORT/checkhealth | grep -q '"success":true'
  WEB_STATUS=$?
  sleep 1
  ((TIME_WAIT=TIME_WAIT+1))
  echo -n .
done

echo
echo "应用启动成功，耗时 $TIME_WAIT 秒"
